/**
 * @class   wosh::building::GardenZone
 * @brief   BuildingObject representing a generic (real) floor.
 *          wosh::building::GardenZone is usually a child of wosh::building::House
 *
 ****************************************************************************
 * @version $Id: GardenZone.h 2891 2010-08-12 01:58:59Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

#ifndef __WOSH_Building_GardenZone_H__
 #define __WOSH_Building_GardenZone_H__

 #include <framework/building/BuildingObject.h>


namespace wosh {
 namespace building {

 #define _GardenZone_VERSION					0.02

 #define _GardenZone_METHOD_lights_on			"lights_on"
 #define _GardenZone_METHOD_lights_off			"lights_off"

 #define _GardenZone_METHOD_open				"open"
 #define _GardenZone_METHOD_close				"close"


class GardenZone : public BuildingObject
 {
	WOSH_BUILDINGOBJECT(wosh::building::GardenZone)

	public:
		/**
		 * @brief  Empty constructor.
		 */
		GardenZone();
		/**
		 * @brief  Copy constructor.
		 * @param m [in] the source object to be copied
		 */
		GardenZone( const GardenZone& m ) : BuildingObject(m) { }
		/**
		 * @brief  Empty destructor.
		 */
		virtual ~GardenZone() { }


	public:
		virtual void busMessageChild( const Message& message );



	public:
		inline int64 getID() const						{ return this->uid; }
		inline bool isEnabled() const					{ return this->enabled; }
		inline long getPriority() const					{ return this->priority; }

		inline long getLimitTimeMin() const				{ return this->time_min; }
		inline long getLimitTimeMax() const				{ return this->time_max; }
		inline long getLimitWaterLevel() const			{ return this->water_level; }
		inline long getLimitTimePeriod() const			{ return this->time_period; }

	public:
		inline void setEnabled( bool value )			{ this->enabled = value; }
		inline void setPriority( long value )			{ this->priority = value; }

		inline void setLimitTimeMin( long value )		{ this->time_min = value; }
		inline void setLimitTimeMax( long value )		{ this->time_max = value; }
		inline void setLimitWaterLevel( long value )	{ this->water_level = value; }
		inline void setLimitTimePeriod( long value )	{ this->time_period = value; }

		void clear() {
			this->enabled = true;
			this->priority = 0;
		 }
		void clearLimits() {
			this->time_min = 0;
			this->time_max = 0;
			this->time_period = 0;
			this->water_level = 0;
		 }


//@}
/** @name GardenZone Interface - 
 * @{
 ******************************************************************************/
	public:
		virtual WRESULT lightsTurnOn()				{ return mmDoLightsTurnOn(NULL); }
		virtual WRESULT lightsTurnOff()				{ return mmDoLightsTurnOff(NULL); }
//@}
	private:
		WRESULT mmDoLightsTurnOn( const SecurityToken* security );
		WRESULT mmDoLightsTurnOff( const SecurityToken* security );

		WRESULT mmDoWaterOpen( const SecurityToken* security );
		WRESULT mmDoWaterClose( const SecurityToken* security );

	protected:
		virtual void init();

	protected:
		int64 uid;					///<
		bool enabled;				///<
		long priority;				///<

	protected: // limits
		long time_min;				///< minimum time in seconds foreach session. 0=disabled
		long time_max;				///< maximum time in seconds foreach session. 0=disabled

		long water_level;			///< millimeters per period (= 1 liter / m^2)

		long time_period;			///< period in seconds between each session


}; // class def

 }; // namespace building
}; // namespace wosh

#endif //__WOSH_Building_GardenZone_H__
